﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DAL.Connect;
using DAL.Classes;

public partial class UserControl_UCBaiDangTheoTaiKhoan2 : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            PopulateControls();
        }
    }
    private void PopulateControls()
    {
        int howManyPages = 0;
        string trang = Request.QueryString["Trang"] ?? "1";
        string maTheLoai = Request.QueryString["TheLoaiID"] ?? "";
        string maTaiKhoan = Request.QueryString["TaiKhoanID"] ?? "";
        string firstPageUrl = "";
        string pagerFormat = "";
        if (maTaiKhoan != "")
        {
            dlAlbumList.DataSource = BaiDang.BaiDangTheoTaiKhoan_TheLoai(maTaiKhoan, trang, out howManyPages);
            dlAlbumList.DataBind();
            int demTheLoai1 = BaiDang.DemBaiDangTheoMaTaiKhoan_TheLoai(maTaiKhoan, "1");
            int demTheLoai2 = BaiDang.DemBaiDangTheoMaTaiKhoan_TheLoai(maTaiKhoan, "2");
            lbResults.Text = "Tổng số Bài đăng cho hình ảnh là: '" + demTheLoai1 + "' và Video là: '" + demTheLoai2 + "'";
            firstPageUrl = Link.DenTaiKhoan(maTaiKhoan);
            pagerFormat = Link.DenTaiKhoan(maTaiKhoan, "{0}");
        }
        PagerBottom.Show(int.Parse(trang), howManyPages, firstPageUrl, pagerFormat, true);
    }
}
